package bookstore.controller;
import bookstore.model.User;
import bookstore.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RestController
public class UserController {
    @Autowired
    UserService userService;
    //注册
    @RequestMapping("/regiset")
    public Object regiset(String name, String password) {
        User userModel=new User();
        userModel.setName(name);
        userModel.setPas(password);
        return userService.addUser(userModel);
    }
    //登陆
    @RequestMapping("/login")
    public Object login(String name,String password){
        Map map=new HashMap();
        map.put("name",name);
        map.put("pas",password);
        return userService.login(map);
    }
}
